package org.learn.java;

public class Permute {

	public void permuteSample(int n, int m) {
		int a[] = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = i;

		for (int i = 0; i < n; i++)
			System.out.print(a[i] + " ");

		for (int i = 0; i < m; i++) {
			int r = i + (int) (Math.random() * (n - i));
			int t = a[r];
			a[r] = a[i];
			a[i] = t;
		}

		System.out.println();
		for (int i = 0; i < n; i++)
			System.out.print(a[i] + " ");
	}

	public static void main(String[] args) {
		Permute permute = new Permute();
		permute.permuteSample(1000, 100);
	}

}
